package pe.com.gromero.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingErrorProcessor;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import pe.com.gromero.domain.Broker;
import pe.com.gromero.service.BrokerService;

@Controller
public class HomePageController {
	@Autowired
	BrokerService brokerService;

	@RequestMapping(value = "/formulario", method = RequestMethod.GET)
	public ModelAndView broker() {
		return new ModelAndView("formulario", "comando", new Broker());
	}

	@RequestMapping("/getList")
	public ModelAndView getBrokerList() {
		List<Broker> brokerList = brokerService.getUserList();
		return new ModelAndView("brokerList", "brokerList", brokerList);
	}
	
	@RequestMapping(value="/busqueda", method=RequestMethod.POST)
	public String buscarBroker(@ModelAttribute("broker") Broker broker, BindingResult resultado){
		
		System.out.print("asdfasd"+ broker.getCN_CORRELATIVO());
		return "redirect:formulario";
	}
	




}
